package com.cyl.manager.message.controller;

import java.util.List;

import com.cyl.manager.message.domain.convert.FhIndexMessageConvert;
import com.cyl.manager.message.domain.entity.FhIndexMessage;
import com.cyl.manager.message.domain.query.FhIndexMessageQuery;
import com.cyl.manager.message.domain.vo.FhIndexMessageVO;
import com.cyl.manager.message.service.FhIndexMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;



import com.ruoyi.common.utils.poi.ExcelUtil;
/**
 * 通知列表Controller
 *
 * @author zcc
 * @date 2025-06-17
 */
@Api(description ="通知列表接口列表")
@RestController
@RequestMapping("/message/fhIndexMessage")
public class FhIndexMessageController extends BaseController {
    @Autowired
    private FhIndexMessageService service;
    @Autowired
    private FhIndexMessageConvert convert;

    @ApiOperation("查询通知列表列表")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<FhIndexMessage>> list(@RequestBody FhIndexMessageQuery query, Pageable page) {
        List<FhIndexMessage> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("导出通知列表列表")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:export')")
    @Log(title = "通知列表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public ResponseEntity<String> export(FhIndexMessageQuery query) {
        List<FhIndexMessage> list = service.selectList(query, null);
        ExcelUtil<FhIndexMessageVO> util = new ExcelUtil<>(FhIndexMessageVO.class);
        return ResponseEntity.ok(util.writeExcel(convert.dos2vos(list), "通知列表数据"));
    }

    @ApiOperation("获取通知列表详细信息")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<FhIndexMessage> getInfo(@PathVariable("id") Integer id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增通知列表")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:add')")
    @Log(title = "通知列表", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody FhIndexMessage fhIndexMessage) {
        return ResponseEntity.ok(service.insert(fhIndexMessage));
    }

    @ApiOperation("修改通知列表")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:edit')")
    @Log(title = "通知列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody FhIndexMessage fhIndexMessage) {
        return ResponseEntity.ok(service.update(fhIndexMessage));
    }

    @ApiOperation("删除通知列表")
    @PreAuthorize("@ss.hasPermi('message:fhIndexMessage:remove')")
    @Log(title = "通知列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
